using UnityEngine;

namespace LS.SimpleInput
{
    public class SingleInputerGestureStates
    {
        public PointInputer inputer;
        public TriggerGestureState tap;
        public TimerGestureState longTap;
        public DoubleTriggerGestureState doubleTap;
        public MovementGestureState swipe;

        public bool Actived
        {
            get
            {
                return tap.Active || longTap.Active || doubleTap.Active || swipe.Active;
            }
        }

        public SingleInputerGestureStates() : this(null)
        {

        }

        public SingleInputerGestureStates(PointInputer inputer)
        {
            this.inputer = inputer;
            tap = new TriggerGestureState()
            {
                GestureType = GestureType.Tap,
            };

            longTap = new TimerGestureState()
            {
                GestureType = GestureType.LongTap,
            };

            doubleTap = new DoubleTriggerGestureState()
            {
                GestureType = GestureType.Tap,
            };

            swipe = new MovementGestureState()
            {
                GestureType = GestureType.Swipe,
            };
        }

        public void Update()
        {
            UpdateTap();
            UpdateLongTap();
            UpdateDoubleTap();
            UpdateSwipe();
        }

        private void UpdateTap()
        {
            GestureStateUtility.UpdateTapFrame(tap, inputer);
        }

        private void UpdateLongTap()
        {
            GestureStateUtility.UpdateLongTapFrame(longTap, inputer);
        }

        private void UpdateDoubleTap()
        {
            GestureStateUtility.UpdateDoubleTapFrame(doubleTap, inputer);
        }

        private void UpdateSwipe()
        {

        }

    }
}
